package service.impl;

import bean.dto.Login;
import bean.dto.UserRoomList;
import bean.pojo.User;
import bean.vo.UserVo;
import dao.UserDao;
import dao.impl.UserDaoImpl;
import service.UsersService;

import java.util.List;

/**
 * service.impl
 * User: mcw
 * Date: 2024/12/16 下午6:59
 * motto:   春天（spring）没有虫子（bug)
 * Description:
 * Version: V1.0
 */
public class UsersServiceImpl implements UsersService {
    private UserDao userDao=new UserDaoImpl();
    /**
     *获取用户的角色信息
     * @param userId
     * @return
     */
    @Override
    public UserVo infoRole(Integer userId) {
        return userDao.getInfoRole(userId);
    }

    /**
     * 登录
     * @param login
     * @return
     */
    @Override
    public User login(Login login) {
        return userDao.login(login);
    }

    @Override
    public Long findByTotal(Integer userId, String userName, String userSex,Integer userAge, String idCardNumber, String userPhone, Integer isOwner, Integer roomId) {
        return userDao.findByTotal(userId,userName,userSex,userAge,idCardNumber,userPhone,isOwner,roomId);
    }

    @Override
    public List<UserRoomList> userFindBy(Integer page, Integer limit, Integer userId, String userName, String userSex, Integer userAge, String idCardNumber, String userPhone, Integer isOwner, Integer roomId) {
        return userDao.userFindBy(page, limit,userId,userName,userSex,userAge,idCardNumber,userPhone,isOwner,roomId);
    }

    @Override
    public Boolean add(User user) {
        return userDao.add(user)>0;
    }

    @Override
    public Boolean update(User user) {
        return userDao.update(user)>0;
    }

    /**
     * 查询用户是否存在
     * @param userName
     * @return
     */
    @Override
    public Boolean tfExistUserName(String userName) {
        return userDao.tfExistUserName(userName);
    }

    /**
     * 用户注册
     * @param user
     * @return
     */
    @Override
    public Integer registerUser(User user) {
        return userDao.registerUser(user);
    }

    /**
     * 根据id查找用户新
     * @param userId
     * @return
     */
    @Override
    public User findUserById(Integer userId) {
        return userDao.findUserById(userId);
    }

    /**
     * 修改用户基本信息
     * @param user
     * @param userId
     * @return
     */
    @Override
    public Integer updatePersonalInfo(User user, Integer userId) {
        return userDao.updatePersonalInfo(user,userId);
    }

    /**
     * 查询除了登录用户外是否还有相同的用户名
     * @param userName
     * @param userId
     * @return
     */
    @Override
    public Boolean tfExistName(String userName, Integer userId) {
        return userDao.tfExistName(userName,userId);
    }

    @Override
    public boolean updateAvatar(Integer userId, String serverPath) {
        return userDao.updateAvatar(userId,serverPath)>0;
    }

    @Override
    public User findFacePhoto(Integer userId) {
        return userDao.findFacePhoto(userId);
    }

    @Override
    public Boolean deleteById(Integer userId) {
        return userDao.deleteById(userId)>0;
    }
}
